package com.ruoyi.chengji.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.pingjiao.domain.Coureassess;
import com.ruoyi.pingjiao.domain.CourseassessName;
import com.ruoyi.pingjiao.domain.query.CoureassessQueryParam;
import com.ruoyi.pingjiao.service.CourseAssessNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("score/courseAssessName")
public class CourseAssessNameController extends BaseController {
    @Autowired
    private CourseAssessNameService courseAssessNameService;
    //查询所有数据
    @GetMapping("list")
    public AjaxResult list(CoureassessQueryParam coureassessQueryParam){
        System.out.println(coureassessQueryParam);
        List<CourseassessName> list = courseAssessNameService.list(coureassessQueryParam);
        return AjaxResult.success(list);
    }

    //查询所有数据
    @GetMapping("listAll")
    public AjaxResult listAll(CourseassessName courseassessName){
        List<CourseassessName>list=courseAssessNameService.listAll(courseassessName);
        return AjaxResult.success(list);
    }

//    @GetMapping("listAll")
//    public AjaxResult listAll(){
//
//    }
    //导出评价报告
    @PostMapping("export")
    public void export(HttpServletResponse response,  CourseassessName courseassessName) throws Exception {
        courseAssessNameService.export(response,courseassessName);

    }
    @PostMapping("add")
    public AjaxResult add(@RequestBody CourseassessName courseassessName){
        return toAjax(courseAssessNameService.add(courseassessName));
    }
    @PutMapping("update")
    public AjaxResult update(@RequestBody CourseassessName courseassessName){
        System.out.println("update:"+courseassessName);
        return toAjax(courseAssessNameService.updateInfo(courseassessName));
    }
    @DeleteMapping("{id}")
    public AjaxResult delete(@PathVariable Long[] id){
        return toAjax(courseAssessNameService.delete(id));
    }
    @GetMapping("getInfo/{id}")
    public AjaxResult getCourseassessName(@PathVariable Long id){
        return AjaxResult.success(courseAssessNameService.selectById(id));
    }
}
